/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xq.gwt.ui.test;

import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

/**
 *
 * @author amonra
 */
public class RecordForm extends DynamicForm {    
    private ListGridField[] entityFields;

    public void setEntityFields(ListGridField[] fields) {
        this.entityFields = fields;
        FormItem[] formItems = new FormItem[entityFields.length];
        for (int i = 0; i < entityFields.length; i++) {
            TextItem textEdit = new TextItem(entityFields[i].getName(), entityFields[i].getTitle());
            formItems[i] = textEdit;
        }
        this.clearValues();
        this.setFields(formItems);
    }
    

    public void setCurrentRecord(ListGridRecord currentRecord) {        
        this.editRecord(currentRecord);
        this.redraw();
    }

    

}
